﻿package com.gxr.servlet;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import util.StrConvert;

import com.dao.ObjectDao;
import com.pro.bean.Unit;

public class AddCmpServlet extends HttpServlet {

	/**
	 * ����admin_super_cmp_add.jsp��� ������ݿ� ת��admin_super_cmp_view.jsp
	 */
	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {

		doPost(request,response);
	}


	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {

		String cmpname= StrConvert.ToCN(request.getParameter("cmpname"));
		System.out.println("addCmoServlet"+cmpname);
		
		Unit unit=new Unit();
		unit.setUnitname(cmpname);
		
		ObjectDao objectDao =new ObjectDao(); 
		try {
			objectDao.add(unit, objectDao.NOTINSERTID);
		} catch (SecurityException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (NoSuchMethodException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		response.sendRedirect("SearchCmpServlet");
	}

}
